home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / mint96sb.zoo / src / inline.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-10-06  |  1.8 KB  |  84 lines

  1. /*
  2. Copyright 1992 Eric R. Smith. All rights reserved.
  3.  */
  4.  
  5. /*
  6.  * inlining of various utility functions, for speed
  7.  * NOTE: ALL functions in this file must also have
  8.  * "normal" equivalents in the .c or .s files;
  9.  * don't put a function just into here!
  10.  */
  11.  
  12. #ifdef __GNUC__
  13.  
  14. #define spl7()            \
  15. ({  register short retvalue;    \
  16.     __asm__ volatile("        \
  17.     movew sr,%0;         \
  18.     oriw  #0x0700,sr "     \
  19.     : "=r"(retvalue)         \
  20.     ); retvalue; })
  21.  
  22. #define spl(N)            \
  23. ({                  \
  24.     __asm__ volatile("        \
  25.     movew %0,sr "         \
  26.     :                \
  27.     : "g"(N) ); })
  28.  
  29.  
  30. /*
  31.  * note that we must save some registers ourselves,
  32.  * or else gcc will run out of reggies to use
  33.  * and complain
  34.  */
  35.  
  36. #define callout1(func, a)            \
  37. ({                        \
  38.     register long retvalue __asm__("d0");    \
  39.     long _f = func;                \
  40.     short _a = (short)(a);            \
  41.                         \
  42.     __asm__ volatile            \
  43.     ("  moveml d5-d7/a4-a6,sp@-;        \
  44.         movew %2,sp@-;            \
  45.         jsr %1@;                \
  46.         addqw #2,sp;            \
  47.         moveml sp@+,d5-d7/a4-a6 "        \
  48.     : "=r"(retvalue)    /* outputs */    \
  49.     : "a"(_f), "r"(_a)    /* inputs */    \
  50.     : "d0", "d1", "d2", "d3", "d4",        \
  51.       "a0", "a1", "a2", "a3" /* clobbered regs */ \
  52.     );                    \
  53.     retvalue;                \
  54. })
  55.  
  56. #define callout2(func, a, b)            \
  57. ({                        \
  58.     register long retvalue __asm__("d0");    \
  59.     long _f = func;                \
  60.     short _a = (short)(a);            \
  61.     short _b = (short)(b);            \
  62.                         \
  63.     __asm__ volatile            \
  64.     ("  moveml d5-d7/a4-a6,sp@-;        \
  65.         movew %3,sp@-;            \
  66.         movew %2,sp@-;            \
  67.         jsr %1@;                \
  68.         addqw #4,sp;            \
  69.         moveml sp@+,d5-d7/a4-a6 "        \
  70.     : "=r"(retvalue)    /* outputs */    \
  71.     : "a"(_f), "r"(_a), "r"(_b) /* inputs */ \
  72.     : "d0", "d1", "d2", "d3", "d4",        \
  73.       "a0", "a1", "a2", "a3" /* clobbered regs */ \
  74.     );                    \
  75.     retvalue;                \
  76. })
  77.  
  78. #endif
  79.  
  80. #ifdef LATTICE
  81. #pragma inline d0=spl7()    {"40c0007c0700";}
  82. #pragma inline d0=spl(d0)    {"46c0";}
  83. #endif
  84.